import { IButtonMenu, IDomEditor } from "@wangeditor/editor";

class PreviewMenu implements IButtonMenu {
  tag: string;
  title: string;
  iconSvg: string;

  constructor() {
    this.title = "预览"; // 鼠标悬浮显示
    this.tag = "button";
    this.iconSvg =
      '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448zm0 64a160.192 160.192 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"></path></svg>'; // 菜单图标
  }

  isActive(editor: IDomEditor): boolean {
    // 保持默认
    return false;
  }

  getValue(editor: IDomEditor): string | boolean {
    // 保持默认
    return "";
  }

  isDisabled(editor: IDomEditor): boolean {
    // 保持默认
    return false;
  }

  exec(editor: IDomEditor, value: string | boolean) {
    // 菜单点击事件，这里将点击事件暴露出去
    if (this.isDisabled(editor)) {
      return;
    }
    editor.emit("PreviewMenuClick");
  }
}

export default PreviewMenu;
